import 'package:OASys/entity/MenuTreeVo.dart';
import 'package:OASys/entity/MenuVo.dart';
import 'package:OASys/httpConfig/DioManager.dart';
import 'package:OASys/httpConfig/ErrorEntity.dart';
import 'package:OASys/httpConfig/NWMethod.dart';

class MenuApi {
  void tree({Function(List<MenuTreeVo>) success, Function(ErrorEntity) error}) {
    DioManager().requestList<MenuTreeVo>(
      NWMethod.GET,
      "/front/menu/tree",
      success: success,
      error: error,
    );
  }

  void list({Function(List<MenuVo>) success, Function(ErrorEntity) error}) {
    DioManager().requestList<MenuVo>(
      NWMethod.GET,
      "/front/menu/list",
      success: success,
      error: error,
    );
  }

  void save(MenuVo info,
      {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.POST,
      "/front/menu/save",
      params: info.toJson(),
      success: success,
      error: error,
    );
  }

  void remove(int id, {Function(String) success, Function(ErrorEntity) error}) {
    DioManager().request<String>(
      NWMethod.DELETE,
      "/front/menu/$id",
      success: success,
      error: error,
    );
  }
}
